import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

//重新下载路由也能解决这个问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err);
};

export default new Router({
	linkActiveClass: "active-class",
	routes: [{
			path: "/",
			redirect: {
				name: "find"
			}
		},
		{
			path: "/find",
			name: "find",
			component: () =>
				import("./views/find/find.vue"),
			meta: {
				title: "发现",
				isTopNav: true,
				isBtnNav: true
			},
			children: [{
					path: "/find/",
					name: "newAblum",
					//				hash: "/find/",
					component: () =>
						import("./views/find/children/child/newAblum.vue"),
					meta: {
						title: "新碟",
						isTopNav: true,
						isBtnNav: true
					}
				},
				{
					path: "/find/newmusic",
					name: "newmusic",
					//				hash: "/find/newmusic",
					component: () =>
						import("./views/find/children/child/newmusic.vue"),
					meta: {
						title: "新歌",
						isTopNav: true,
						isBtnNav: true
					}
				}
			]
		},
		{
			path: "/find/recommendmusic",
			name: "recommendmusic",
			component: () =>
				import("./views/find/recommendmusic.vue"),
			meta: {
				title: "推荐歌曲",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/find/musicplaylist",
			name: "musicplaylist",
			component: () =>
				import("./views/find/musicplaylist.vue"),
			meta: {
				title: "推荐歌单",
				isTopNav: false,
				isBtnNav: false
			},
			children: [{
					path: "/boutique/",
					name: "boutique",
					component: () =>
						import("./views/find/musicplaylistchild/boutique.vue"),
					meta: {
						title: "精品",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/chinese/",
					name: "chinese",
					component: () =>
						import("./views/find/musicplaylistchild/chinese.vue"),
					meta: {
						title: "华语",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/electronic/",
					name: "electronic",
					component: () =>
						import("./views/find/musicplaylistchild/electronic.vue"),
					meta: {
						title: "电子",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/folk/",
					name: "folk",
					component: () =>
						import("./views/find/musicplaylistchild/folk.vue"),
					meta: {
						title: "民谣",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/lightmusic/",
					name: "lightmusic",
					component: () =>
						import("./views/find/musicplaylistchild/lightmusic.vue"),
					meta: {
						title: "轻音乐",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/official/",
					name: "official",
					component: () =>
						import("./views/find/musicplaylistchild/official.vue"),
					meta: {
						title: "官方",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/popular/",
					name: "popular",
					component: () =>
						import("./views/find/musicplaylistchild/popular.vue"),
					meta: {
						title: "流行",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/find/musicplaylist/",
					name: "recMusicplaylist",
					component: () =>
						import("./views/find/musicplaylistchild/recMusicplaylist.vue"),
					meta: {
						title: "推荐",
						isTopNav: false,
						isBtnNav: false
					}
				}
			]
		},
		{
			path: "/musiclist",
			name: "musiclist",
			component: () =>
				import("./views/find/musiclist.vue"),
			meta: {
				title: "排行榜",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/radiolist",
			name: "radiolist",
			component: () =>
				import("./views/find/radiolist.vue"),
			meta: {
				title: "电台",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/musiclistdetail",
			name: "musiclistdetail",
			component: () =>
				import("./views/find/musiclistdetail.vue"),
			meta: {
				title: "歌单详情",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/musiclistcommon",
			name: "musiclistcommon",
			component: () =>
				import("./views/find/musiclistcommon.vue"),
			meta: {
				title: "歌单评论",
				isTopNav: false,
				isBtnNav: false
			}
		},
		
		{
			path: "/radiodetail",
			name: "radiodetail",
			component: () =>
				import("./views/find/radiodetail.vue"),
			meta: {
				title: "电台详情",
				isTopNav: false,
				isBtnNav: false
			},
			children: [{
					path: "/detail",
					name: "detail",
					component: () =>
						import("./views/find/radiodetailchildren/detail.vue"),
					meta: {
						title: "详情",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/show",
					name: "show",
					component: () =>
						import("./views/find/radiodetailchildren/show.vue"),
					meta: {
						title: "节目",
						isTopNav: false,
						isBtnNav: false
					}
				}
			],
		},

		{
			path: "/mine",
			name: "mine",
			component: () =>
				import("./views/mine/mine.vue"),
			meta: {
				title: "我的",
				isTopNav: true,
				isBtnNav: true
			}
		},
		{
			path: "/yuncun",
			name: "yuncun",
			component: () =>
				import("./views/yuncun/yuncun.vue"),
			children: [
				// {
				// 	path: "/yuncun/",
				// 	name: "square",
				// 	component: () =>
				// 		import("./views/yuncun/children/square.vue"),
				// 	meta: {
				// 		title: "广场",
				// 		isTopNav: true,
				// 		isBtnNav: true
				// 	}
				// },
				{
					path: "/yuncun/",
					name: "dynamic",
					component: () =>
						import("./views/yuncun/children/dynamic.vue"),
					meta: {
						title: "动态",
						isTopNav: true,
						isBtnNav: true
					}
				}
			],
			meta: {
				title: "云村",
				isTopNav: true,
				isBtnNav: true
			}
		},
		{
			path: "/yuncun/dynamicDetails",
			name: "dynamicDetails",
			component: () =>
				import("./views/yuncun/children/dynamicDetails/dynamicDetails.vue"),
			meta: {
				title: "动态详情",
				isTopNav: false,
				isBtnNav: false
			},
			children: [{
					path: '/yuncun/dynamicDetails/:arr',
					name: "dynamicReview",
					component: () =>
						import("./views/yuncun/children/dynamicDetails/dynamicReview.vue"),
					meta: {
						title: "动态评价",
						isTopNav: false,
						isBtnNav: false
					},
				},
				{
					path: '/yuncun/dynamicDetails/dynamicForward',
					name: "dynamicForward",
					component: () =>
						import("./views/yuncun/children/dynamicDetails/dynamicForward.vue"),
					meta: {
						title: "动态转发",
						isTopNav: false,
						isBtnNav: false
					},
				},
				{
					path: '/yuncun/dynamicDetails/dynamicFabulous',
					name: "dynamicFabulous",
					component: () =>
						import("./views/yuncun/children/dynamicDetails/dynamicFabulous.vue"),
					meta: {
						title: "动态点赞",
						isTopNav: false,
						isBtnNav: false
					},
				}
			]
		},
		{
			path: "/myvideo",
			name: "myvideo",
			component: () =>
				import("./views/video/myvideo.vue"),
			meta: {
				title: "视频",
				isTopNav: true,
				isBtnNav: true
			}
		},

		{
			path: "/rankingList",
			name: "rankingList",
			component: () =>
				import("./views/video/rankingList/rankingList.vue"),
			meta: {
				title: "MV排行榜",
				isTopNav: false,
				isBtnNav: false
			},
			children: [{
					path: "/",
					redirect: {
						name: "inland"
					}
				},
				{
					path: "/rankingList/inland",
					name: "inland",
					component: () =>
						import("./views/video/rankingList/Inland.vue"),
					meta: {
						title: "内地",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/rankingList/korea",
					name: "korea",
					component: () =>
						import("./views/video/rankingList/korea.vue"),
					meta: {
						title: "韩国",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/rankingList/hongKong",
					name: "hongKong",
					component: () =>
						import("./views/video/rankingList/hongKong.vue"),
					meta: {
						title: "港台",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/rankingList/america",
					name: "america",
					component: () =>
						import("./views/video/rankingList/america.vue"),
					meta: {
						title: "欧美",
						isTopNav: false,
						isBtnNav: false
					}
				},
				{
					path: "/rankingList/japan",
					name: "japan",
					component: () =>
						import("./views/video/rankingList/japan.vue"),
					meta: {
						title: "日本",
						isTopNav: false,
						isBtnNav: false
					}
				}
			]
		},
		{
			path: "/search",
			name: "search",
			component: () =>
				import("./views/search/search.vue"),
			meta: {
				title: "搜索",
				isTopNav: false,
				isBtnNav: true
			}
		},
		{
			path: "/login",
			name: "login",
			component: () =>
				import("./views/login/login.vue"),
			meta: {
				title: "登录",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/phoneLogin",
			name: "phoneLogin",
			component: () =>
				import("./views/login/phoneLogin.vue"),
			meta: {
				title: "手机登录",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/password",
			name: "password",
			component: () =>
				import("./views/login/password.vue"),
			meta: {
				title: "密码",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/phoneyanzheng",
			name: "phoneyanzheng",
			component: () =>
				import("./views/login/phoneyanzheng.vue"),
			meta: {
				title: "验证",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/mvdetails/:id",
			name: "mvdetails",
			component: () =>
				import("./views/video/mvDetails/mvDetail.vue"),
			meta: {
				title: "登录",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/createedit",
			name: "createedit",
			component: () =>
				import("./views/mine/children/createSong/createedit.vue"),
			meta: {
				title: "编辑歌单",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/name",
			name: "name",
			component: () =>
				import("./views/mine/children/createSong/createedit/name.vue"),
			meta: {
				title: "歌单名称",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/createeditlabel",
			name: "createeditlabel",
			component: () =>
				import("./views/mine/children/createSong/createedit/createeditlabel.vue"),
			meta: {
				title: "歌单标签",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/description",
			name: "description",
			component: () =>
				import("./views/mine/children/createSong/createedit/description.vue"),
			meta: {
				title: "歌单介绍",
				isTopNav: false,
				isBtnNav: false
			}
		},
		{
			path: "/songdetails",
			name: "songdetails",
			component: () =>
				import("./views/mine/children/songdetails.vue"),
			meta: {
				title: "歌单歌曲",
				isTopNav: false,
				isBtnNav: false
			}
    },
    {
      path: "/musicPlayPage",
      name: "musicPlayPage",
      component: () => import("./views/musicPlayPage/musicPlayPage.vue"),
      meta: {
        title: "音乐播放页",
        isTopNav: false,
        isBtnNav: false
      }
    },
    {
      path: "/musicPlayPageComment",
      name: "musicPlayPageComment",
      component: () => import("./views/musicPlayPageComment/musicPlayPageComment.vue"),
      meta: {
        title: "歌曲评论页",
        isTopNav: false,
        isBtnNav: false
      }
    }
	],
	scrollBehavior(to, from, savedPosition) {
		// 切换组件的时候，使得组件滚动到顶部
		return {
			x: 0,
			y: 0
		};
	}
});
